home *** CD-ROM | disk | FTP | other *** search
- Path: swidir.switch.ch!epflnews!Thomas.Wolf
- From: Thomas.Wolf@di.epfl.ch (Thomas Wolf)
- Newsgroups: comp.arch.arithmetic,comp.lang.c,comp.lang.c++
- Subject: Re: Access carry flag from C
- Date: 27 Feb 1996 17:02:35 GMT
- Organization: Ecole Polytechnique FΘdΘrale de Lausanne
- Sender: wolf@lglsun5.epfl.ch (Thomas Wolf)
- Message-ID: <4gvdfb$qjb@info.epfl.ch>
- References: <Dn1C9z.DGv.0.net@indra.com> <n4mwd.40.0010633E@magg.net> <3129DF54.7DC5@hda.hydro.com> <3132f4ea.33276048@netline-fddi.jpl.nasa.gov>
- NNTP-Posting-Host: lglsun5.epfl.ch
-
- In article <3132f4ea.33276048@netline-fddi.jpl.nasa.gov>, kdq@emoryi.jpl.nasa.gov (Kevin Quitt) writes:
- :> On Tue, 20 Feb 1996 15:48:52 +0100, Terje Mathisen
- :> <Terje.Mathisen@hda.hydro.com> wrote:
- :> >A much more portable solution looks like this:
- :> >
- :> >unsigned i, j, k;
- :> >
- :> > i = j + k;
- :> > if (i < j) /* Overflowed! */ ... ; // You can also do "if (i < k)" of course!
- :>
- :> How can this be portable? The overflow causes undefined behaviour, so nothing
- :> following can be correct.
-
- Unsigned arithmetic cannot overflow. The ANSI/ISO standard for the C
- programming language defines modulo-arithmetic for unsigned integer types
- (ISO/IEC 9899:1990(E), 6.1.2.5, page 23, first paragraph).
-
- Regards,
-
- Thomas
- ----------------------------------------------------------------------
- Swiss Federal Institute of Technology | Thomas Wolf
- Software Engineering Laboratory | EPFL-DI-LGL
- Thomas Wolf (TW) | CH-1015 Lausanne (Suisse)
- E-Mail: wolf@di.epfl.ch | Phone: (++41 21)693 42 37
- ----------------------------------------------------------------------
-